﻿using System;
using ASPNETVN.PORTAL.Modules.ACTP.Components;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.Helpers;

namespace ASPNETVN.PORTAL.Modules.ACTP.Controls
{
    public partial class TaskList : ModulePage
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            btnAdd.Visible = this.IsAddable;
            gvList.Columns[gvList.Columns.Count - 1].Visible = this.IsEditable;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                gvList.DataSource = Task.SelectCollectionAll(this.ModuleID);
                gvList.DataBind();
            }
        }

        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            gvList.DataSource = Task.SelectCollectionAll(this.ModuleID);
            gvList.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string url = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditTask");
            Response.Redirect(url);
        }
    }
}